import 'package:flutter/material.dart';
import 'package:dodoclub/pages/comm/method_bridge.dart';

class PersonPage extends StatefulWidget {
  const PersonPage({Key? key}) : super(key: key);

  @override
  _PersonPageState createState() => _PersonPageState();
}

class _PersonPageState extends State<PersonPage> {
  late ThemeData theme;

  bool _switchValue1 = true;
  bool _switchValue2 = false;
  bool _switchValue3 = true;
  bool _switchValue4 = false;
  bool _switchValue5 = true;

  @override
  Widget build(BuildContext context) {
    theme = Theme.of(context);
    return Scaffold(
      backgroundColor: theme.scaffoldBackgroundColor,
      // appBar: AppBar(centerTitle: true, title: const Text("Home")),
      appBar: AppBar(
        scrolledUnderElevation: 0.0,
        title: Text(
          'Settings',
        ),
      ),
      body: SafeArea(
        child: Container(
          alignment: Alignment.center,
          child: Container(
            margin: EdgeInsets.fromLTRB(12, 12, 12, 12),
            child: ListView(
              children: <Widget>[
                Container(
                  decoration: BoxDecoration(
                    color: const Color(0xffffffff),
                    // borderRadius: BorderRadius.circular(10),
                    borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(10.0),
                      topRight: Radius.circular(10.0),
                      bottomLeft: Radius.circular(10),
                      bottomRight: Radius.circular(10),
                    ),
                    border:
                        Border.all(color: const Color(0xff7de93b), width: 2.0),
                  ),
                  child: ListTile(
                    leading: const Icon(Icons.all_out),
                    title: const Text('Support random paving'),
                    trailing: Switch(
                      value: _switchValue1,
                      onChanged: (bool value) {
                        setState(() {
                          _switchValue1 = value;
                        });
                        print("Switch 1 is ${value ? 'on' : 'off'}");
                      },
                    ),
                    onTap: () {
                      // 处理点击事件，例如导航到'设置'页面
                    },
                  ),
                ),
                SizedBox(height: 8),
                Container(
                  decoration: BoxDecoration(
                    color: const Color(0xffffffff),
                    // borderRadius: BorderRadius.circular(10),
                    borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(10.0),
                      topRight: Radius.circular(10.0),
                      bottomLeft: Radius.circular(10),
                      bottomRight: Radius.circular(10),
                    ),
                    border:
                        Border.all(color: const Color(0xff7de93b), width: 2.0),
                  ),
                  child: ListTile(
                    leading: Icon(Icons.center_focus_strong),
                    title: Text('Support size display'),
                    trailing: Switch(
                      value: _switchValue2,
                      onChanged: (bool value) {
                        setState(() {
                          _switchValue2 = value;
                        });
                        print("Switch 1 is ${value ? 'on' : 'off'}");
                      },
                    ),
                    onTap: () {
                      // 处理点击事件，例如导航到'设置'页面
                    },
                  ),
                ),
                SizedBox(height: 8),
                Container(
                  decoration: BoxDecoration(
                    color: const Color(0xffffffff),
                    // borderRadius: BorderRadius.circular(10),
                    borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(10.0),
                      topRight: Radius.circular(10.0),
                      bottomLeft: Radius.circular(10),
                      bottomRight: Radius.circular(10),
                    ),
                    border:
                        Border.all(color: const Color(0xff7de93b), width: 2.0),
                  ),
                  child: ListTile(
                    leading: Icon(Icons.collections),
                    title: Text('Support random graphics'),
                    trailing: Switch(
                      value: _switchValue3,
                      onChanged: (bool value) {
                        setState(() {
                          _switchValue3 = value;
                        });
                        print("Switch 1 is ${value ? 'on' : 'off'}");
                      },
                    ),
                    onTap: () {
                      // 处理点击事件，例如导航到'设置'页面
                    },
                  ),
                ),
                SizedBox(height: 8),
                Container(
                  decoration: BoxDecoration(
                    color: const Color(0xffffffff),
                    // borderRadius: BorderRadius.circular(10),
                    borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(10.0),
                      topRight: Radius.circular(10.0),
                      bottomLeft: Radius.circular(10),
                      bottomRight: Radius.circular(10),
                    ),
                    border:
                        Border.all(color: const Color(0xff7de93b), width: 2.0),
                  ),
                  child: ListTile(
                    leading: Icon(Icons.color_lens),
                    title: Text('Support color settings'),
                    trailing: Switch(
                      value: _switchValue4,
                      onChanged: (bool value) {
                        setState(() {
                          _switchValue4 = value;
                        });
                        print("Switch 1 is ${value ? 'on' : 'off'}");
                      },
                    ),
                    onTap: () {
                      // 处理点击事件，例如导航到'设置'页面
                    },
                  ),
                ),
                SizedBox(height: 8),
                Container(
                  decoration: BoxDecoration(
                    color: const Color(0xffffffff),
                    // borderRadius: BorderRadius.circular(10),
                    borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(10.0),
                      topRight: Radius.circular(10.0),
                      bottomLeft: Radius.circular(10),
                      bottomRight: Radius.circular(10),
                    ),
                    border:
                        Border.all(color: const Color(0xff7de93b), width: 2.0),
                  ),
                  child: ListTile(
                    leading: Icon(Icons.view_array),
                    title: Text('Current version'),
                    // trailing: Switch(
                    //   value: _switchValue1,
                    //   onChanged: (bool value) {
                    //     setState(() {
                    //       _switchValue1 = value;
                    //     });
                    //     print("Switch 1 is ${value ? 'on' : 'off'}");
                    //   },
                    // ),
                    trailing: Text(
                      "V1.0",
                      style: TextStyle(fontSize: 18),
                    ),
                    onTap: () {
                      // 处理点击事件，例如导航到'设置'页面
                    },
                  ),
                ),

                SizedBox(height: 8),
                Container(
                  decoration: BoxDecoration(
                    color: Colors.lightGreen,
                    borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(10.0),
                      topRight: Radius.circular(10.0),
                      bottomLeft: Radius.circular(10),
                      bottomRight: Radius.circular(10),
                    ),
                  ),
                  child: ListTile(
                    title: Text(
                      'Exit',
                      textAlign: TextAlign.center, // 对于单行文本，这通常是可选的
                    ),
                    onTap: () {
                      MethodBridge.getInstance().exit();
                    },
                  ),
                ),
                // 可以继续添加更多的ListTile项
              ],
            ),
          ),
        ),
      ),
    );
  }
}
